package com.zc.imooc.finaltest.kafka.adminClient;

import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @program: final-test
 * @description: KafkaAdminClient
 * @author: zengchen
 * @create: 2020-09-18 15:24
 **/
@Component
public class KafkaAdminClient {

    private static AdminClient adminClient;

    public static AdminClient getAdminClient(){
        if(adminClient != null){
            return adminClient;
        }
        Properties properties = new Properties();
        properties.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"centos7-out:9092");
//        properties.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"192.168.10.111:9092");
        adminClient = AdminClient.create(properties);
        return adminClient;
    }

}
